package com.vince.test;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 *  浏览器默认缓存页面
 * 响应头告诉浏览器如何缓存
 *  
 *  
 * @author susp
 *
 */
@WebServlet("/cacheservlet")
public class CacheServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//响应头告诉浏览器如何缓存
		response.setContentType("text/html;charset=utf-8");
		//指定页面不缓存 ,ie
		response.setDateHeader("Expires", -1);
		//为保证兼容性
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Pragma", "no-cache");
		response.getWriter().write("....."+new java.util.Date().toString());
		
	}

}
